<template>
    <el-dialog
    :model-value="dialogVisible"
    :title="dialogTitle"
    width="40"
    @close="handleClose"
  >
  <el-form ref="formRef" label-width="auto" style="max-width: 70px" :rules="rules">
    <el-form-item label="姓名" prop="name">
      <el-input v-model="form.name" />
    </el-form-item>
    <el-form-item label="手机号" prop="phone">
      <el-input v-model="form.phone" />
    </el-form-item>
    <el-form-item label="邮箱" prop="email">
      <el-input v-model="form.email" />
    </el-form-item>

  </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="handleConfirm">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { defineEmits, ref, defineProps } from 'vue'
const emits = defineEmits(['update:modelValue'])
defineProps({
    dialogTitle: {
        type: String,
        default: '新增客户',
        required: true
    }
})

const dialogVisible = ref(false)

const formRef = ref(null)

const form = ref({
    name: '',
    phone: '',
    email: ''
})

const handleClose = () => {
    emits('update:modelValue', false)
}

const handleConfirm = () => {
    handleClose()
}

const rules = ref({
    name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
    phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
    email: [{ required: true, message: '请输入邮箱', trigger: ['blur', 'change'] }]
})
</script>

<style lang="scss" scoped>

</style>
